package com.dapeis.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

import com.ag.dao.DBService;
import com.ag.dao.IDao;
import com.ag.utils.NumberUtils;
import com.dapeis.core.utils.RequirementConfig;
import com.dapeis.core.utils.StylistConstants;
import com.dapeis.dao.IRequirementMapper;
import com.dapeis.domain.Order;
import com.dapeis.domain.Requirement;

/**
 * @author 作者 E-mail:
 * @version 创建时间：2017年4月20日 上午11:07:09 类说明
 */
@Service
public class RequirementService extends DBService<Requirement> {

    @Resource
    IRequirementMapper Mapper;

    @Override
    protected IDao<Requirement> getIDao() {
	return Mapper;
    }

    public boolean isShopRequirement(Order order) {
	if (!order.getType().equalsIgnoreCase(
		StylistConstants.Order.Type.REQUIREMENT)) {
	    return false;
	}
	Example example = new Example(Requirement.class);
	Criteria criteria = example.createCriteria();
	criteria.andEqualTo(Requirement.PROPERTY_ORDERID, order.getId());
	Requirement requirement = selectOneByExample(example);
	if (null == requirement)
	    return false;
	if (NumberUtils.isValid(requirement.getShopId())) {
	    return true;
	}
	return false;
    }
}
